﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Data.SqlClient;

public partial class DictLibary_StuffAliasLibraryImport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click1(object sender, EventArgs e)
    {
        ZWL.BLL.StuffAliasLibrary fileSvr = new ZWL.BLL.StuffAliasLibrary();//导入处理类
        string filename = FileUpload1.PostedFile.FileName.ToString();//客户端文件名
        int filesize = FileUpload1.PostedFile.ContentLength;//文件大小
        if (filesize < 1024 * 1024 * 5)
        {
            string path = Server.MapPath("~/ExcelData/StuffLibarys/");//excel文件服务器端保存路径
            FileUpload1.SaveAs(path + filename);
            System.Data.DataTable dt = fileSvr.GetExcelDatatable(path + filename, "mapTable");
            fileSvr.SqlBulkCopyInsetData(dt);
            Response.Write("<script>alert('批量导入完成');</script>");
        }
        else
        {
            Response.Write("<script>alert('批量导入时发生错误！请重新登陆后重试！');</script>");
        }
    }
    protected void Delete_Click(object sender, EventArgs e)
    {
        if (ZWL.DBUtility.DbHelperSQL.ExecuteSQL("delete from StuffAliasLibrary") == -1)
        {
            Response.Write("<script>alert('清空库时发生错误！请重新登陆后重试！');</script>");
        }
        else
        {
            Response.Write("<script>alert('物资别名库清空完成。');</script>");
            //写系统日志
            ZWL.BLL.ERPRiZhi MyRiZhi = new ZWL.BLL.ERPRiZhi();
            MyRiZhi.UserName = ZWL.Common.PublicMethod.GetSessionValue("UserName");
            MyRiZhi.DoSomething = "用户清空物资别名库基本信息";
            MyRiZhi.IpStr = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();
            MyRiZhi.Add();
        }
    }
}